package ui;

import bbcom.UserInterfaceType;
import bbcom.interfaces.IUserInterfaceParser;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;

/**
 * Created by Thanh-Trung Pham.
 */
public class UserInterfaceParser implements IUserInterfaceParser {
    @Override
    public String getProperty(UserInterfaceType userInterface, String propertyName) {
        if (userInterface == null) {
            return null;
        }

        XmlObject[] oXmlObjects = userInterface.selectPath("$this/@"+propertyName);

        if (oXmlObjects == null || oXmlObjects.length == 0) {
            return null;
        }

        return ((XmlAnyTypeImpl) oXmlObjects[0]).getStringValue();
    }
}
